package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.yingxin.config.YingXinConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eItemId;
import com.yanqu.road.server.manger.activity.yingxin.YingXinMgr;

import java.util.ArrayList;
import java.util.List;

public class YingXinRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        YingXinConfig yingXinConfig = YingXinMgr.getConfig();
        if (yingXinConfig != null) {
            ActivityInfo activityInfo = yingXinConfig.getActivityInfo();
            if (activityInfo != null) {
                long recycleTime = activityInfo.getEndTime() * 1000L + 600 * 1000;
                addMarkItem(activityInfo,eItemId.YINGXIN_ENERGY_RECOVERY_ID.getValue(),eItemId.YINGXIN_SCORE_ITEM.getValue(),1,recycleTime);
                recycleTime = activityInfo.getEndShowTime() * 1000L + 600 * 1000;
                addMarkItem(activityInfo,eItemId.YINGXIN_SILVER_SPOON_ID.getValue(),eItemId.YINGXIN_SCORE_ITEM.getValue(),1,recycleTime);
                addMarkItem(activityInfo,eItemId.YINGXIN_GOLD_SPOON_ID.getValue(),eItemId.YINGXIN_SCORE_ITEM.getValue(),1,recycleTime);
            }
        }
    }

    private void addMarkItem(ActivityInfo activityInfo, int itemId, int scoreItemId, int index,long recycleTime) {
        //标记道具
        List<String> paramList = new ArrayList<>();
        paramList.add(String.valueOf(itemId));
        paramList.add(String.valueOf(scoreItemId));
        paramList.add(String.valueOf(index));
        paramList.add(activityInfo.getActivityName());
        ActivityItemRecycleMgr.addRecycleItemData(itemId, activityType, 1, recycleTime, paramList);
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.YingXinActivity.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        item2Score(userId, data);
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
